package com.jic.order.impl;

import com.jic.common.base.vo.PageResult;
import com.jic.order.entity.OrderError;
import com.jic.order.manage.request.OrderErrorRequest;
import com.jic.order.manage.response.OrderErrorResponse;
import com.jic.order.mapper.OrderErrorMapper;
import com.jic.order.service.OrderErrorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单异常表
 * @author :
 * @email :
 * @since : 2020-03-03 07:17:57
 * @version : v1.0.0
 */
@Service
public class OrderErrorServiceImpl implements OrderErrorService {

    @Autowired
    private OrderErrorMapper orderErrorMapper;

    @Override
    public long insert(OrderError orderError) {
        long flag = orderErrorMapper.insert(orderError);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return orderErrorMapper.delete(id);
    }

    @Override
    public long update(OrderError orderError) {
        return orderErrorMapper.update(orderError);
    }

    @Override
    public OrderError queryByPrimaryKey(Long id){
        return orderErrorMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderError> query(OrderError orderError){
        return orderErrorMapper.query(orderError);
    }

    @Override
    public PageResult<OrderErrorResponse> queryPage(OrderErrorRequest oer) {
        //计算下标
        int startIndex = (oer.getStart() - 1) * oer.getLimit();
        List<OrderErrorResponse> list = orderErrorMapper.queryPage(startIndex, oer);
        long count = orderErrorMapper.queryPageCount(oer);
        PageResult<OrderErrorResponse> pageResult = new PageResult<>();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}
